package com.travel.controller;


import com.travel.dto.HotelDto;
import com.travel.dto.HotelOrderDto;
import com.travel.feign.EsFeign;
import com.travel.service.HotelService;
import com.travel.vo.HotelVo;
import com.travel.vo.RoomVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;

/**
 * 酒店表(Hotel)表控制层
 *
 * @author makejava
 * @since 2023-05-10 14:51:04
 */
@RestController
@RequestMapping("hotel")
@Api("酒店服务")
public class HotelController {

    @Resource
    private EsFeign esFeign;


    /**
     * 服务对象
     */
    @Resource
    private HotelService hotelService;

    @ApiOperation(value = "查询酒店", notes = "根据地区名或酒店名查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "keyWord", value = "城市名称或者酒店名称", required = true, paramType = "query"),
            @ApiImplicitParam(name = "star", value = "酒店星级", required = false, paramType = "query"),
            @ApiImplicitParam(name = "pageNumber", value = "页数",required = false, paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页数据条数",required = false, paramType = "query"),
    })
    @GetMapping("/selectHotelByName")
    public List<HotelVo> selectHotelByName(String keyWord,Integer star, int pageNumber,int pageSize) {
        System.out.println(keyWord+" :keyWord");
        System.out.println(star+" :star");
        System.out.println(pageNumber+" :pageNumber");
        System.out.println(pageSize+" :pageSize");
        return hotelService.selectHotelByName(keyWord, star, pageNumber, pageSize);
    }

    @ApiOperation(value = "查询全部酒店",notes = "查询全部酒店")
    @GetMapping("/selectHotelAll")
    public List<HotelVo> selectHotelAll(){
        return hotelService.selectHotelAll();
    }

    @ApiOperation(value = "根据条件查询酒店",notes = "根据条件查询符合要求的酒店列表")
    @PostMapping("/selectHotelCondition")
    public List<HotelVo> selectHotelCondition(@RequestBody HotelDto hotelDto){
        return hotelService.selectHotelCondition(hotelDto);
    }

    @ApiOperation(value = "查询酒店详情",notes = "根据酒店id查询酒店详细信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name="id",value = "酒店id",required = true,paramType = "query")
    })
    @GetMapping("/selectHotelByHotelId")
    public HotelVo selectHotelByHotelId(Integer id){
        return hotelService.selectHotelByHotelId(id);
    }

    @ApiOperation(value = "查询房间",notes = "根据酒店id查询与之关联的房间")
    @ApiImplicitParams({
            @ApiImplicitParam(name="id",value = "酒店id",required = true,paramType = "query")
    })
    @GetMapping("/selectRoomOfHotel")
    public List<RoomVo> selectRoomOfHotel(Integer id){
        return hotelService.selectRoomOfHotel(id);
    }
    @ApiOperation(value = "查询房间详情",notes = "根据房间id查询房间详细信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name="id",value = "房间id",required = true,paramType = "query")
    })
    @GetMapping("/selectRoomByRoomId")
    public RoomVo selectRoomByRoomId(Integer id){
       return hotelService.selectRoomByRoomId(id);
    }

    @ApiOperation(value = "获取订单id", notes = "获取订单id")
    @GetMapping("/getOrderId")
    public String getOrderId(){
        return hotelService.getOrderId();
    }

    @ApiOperation(value = "创建订单", notes = "根据dto创建hotel order")
    @PostMapping("/createHotelOrder")
    public HashMap<String, String> createHotelOrder(@RequestBody HotelOrderDto hotelOrderDto){
       return hotelService.createHotelOrder(hotelOrderDto);
    }

    @GetMapping("/test")
    public void testFeign(){
        System.out.println(esFeign + "esFeign");
        System.out.println(esFeign + "esFeign");
        String estest = esFeign.estest();
        System.out.println(estest);
    }
}

